package com.woniuxy.platform.core.service.impl;

import com.woniuxy.platform.core.model.PmMessage;
import com.woniuxy.platform.core.mapper.PmMessageMapper;
import com.woniuxy.platform.core.service.PmMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gmx
 * @since 2021-06-30
 */
@Service
public class PmMessageServiceImpl extends ServiceImpl<PmMessageMapper, PmMessage> implements PmMessageService {
    @Resource
    PmMessageMapper pmMessageMapper;


    @Override
    public List<PmMessage> selectAnnouncement() {
        List<PmMessage> pmMessages = this.pmMessageMapper.selectAnnouncement();
        return pmMessages;
    }

    @Override
    public List<PmMessage> selectMesNotice() {
        List<PmMessage> pmMessages = this.pmMessageMapper.selectMesNotice();
        return pmMessages;
    }

    @Override
    public List<PmMessage> selectActivityNotice() {
        List<PmMessage> pmMessages = this.pmMessageMapper.selectActivityNotice();
        return pmMessages;
    }


    @Override
    public int insert(PmMessage pmMessage){
        int i = pmMessageMapper.insert(pmMessage);
        return i;
    }

    @Override
    public List<PmMessage> selectMessage() {
        List<PmMessage> list = this.pmMessageMapper.selectMessage();
        for (PmMessage message :list) {
            if (message.getType()==0){
                message.setChinese("公告消息");
            }
            if (message.getType()==1){
                message.setChinese("消息通知");
            }
            if (message.getType()==2){
                message.setChinese("活动通知");
            }
        }
        return list;
    }

    @Override
    public List<PmMessage> selectMH(PmMessage message) {
        if (message.getChinese().equals("公告信息")){
            message.setType(0);
        }
        if (message.getChinese().equals("消息通知")){
            message.setType(1);
        }
        if (message.getChinese().equals("活动通知")){
            message.setType(2);
        }
        System.out.println(message);
        List<PmMessage> list1 = this.pmMessageMapper.seletMH(message);
        for (PmMessage message1 :list1) {
            if (message1.getType()==0){
                message1.setChinese("公告消息");
            }
            if (message1.getType()==1){
                message1.setChinese("消息通知");
            }
            if (message1.getType()==2){
                message1.setChinese("活动通知");
            }
        }
        return list1;
    }

    @Override
    public List<PmMessage> selectWarning(Integer storeId) {
        return pmMessageMapper.selectWarning(storeId);
    }

    @Override
    public List<PmMessage> slectAll() {

        return this.pmMessageMapper.selectAll();
    }

    @Override
    public List<PmMessage> selectMHH(PmMessage message) {
        List<PmMessage> list = this.pmMessageMapper.seletMH(message);
        return list;
    }
}
